<?php

namespace app\admin\controller;

use app\common\controller\AdminController;
use app\common\model\GoodsBrand;
use app\common\service\annotation\ControllerAnnotation;
use app\common\service\annotation\NodeAnnotation;
use jianyan\excel\Excel;
use think\App;

/**
 * @ControllerAnnotation(title="品牌管理")
 */
class Brand extends AdminController
{
    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->model = new GoodsBrand();
    }

    /**
     * @NodeAnnotation(title="导出")
     */
    public function export(): bool
    {
        // 获取表名
        $header = [] ;
        $header[] = ['ID','id'];
        $header[] = ['品牌名称','name'];
        $list     = $this->model->field('id,name')->select()->toArray();
        $fileName = '品牌参考模版';
        return Excel::exportData($list, $header, $fileName, 'xlsx');
    }
}